package ahut2020.day12;

import java.util.Arrays;

public class ShuffleDemo {
    public static void main(String[] args) {
        int[] a = new int[]{1, 2, 3, 4, 5, 6};
        shuffle(a);
        System.out.println(Arrays.toString(a));
        //
        int[] moneys = genLuckyMoney(500, 5);
    }

    private static int[] genLuckyMoney(int i, int i1) {

        return null;
    }

    private static void shuffle(int[] a) {
        for (int i = 0; i < a.length; i++) {
            //int j= (int) (Math.random()*a.length);//[0,n-1]Uniform
            int j = (int) (Math.random() * (a.length - i)) + i;//在[i,n-1]中间随机选择一个与a[i]置换;
            int t = a[i];
            a[i] = a[j];
            a[j] = t;
        }
    }
}
